package com.network.task;

import com.lmax.disruptor.WorkHandler;
import com.network.endity.FileSave;
import com.network.repository.FileSaveRepository;
import com.network.util.SpringBeanUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 消费者
 */
@Service
public class Consumer<F> implements WorkHandler<FileSave> {

    Logger logger= LoggerFactory.getLogger(Consumer.class);
    @Resource
    FileSaveRepository fileSaveRepository;

    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public void onEvent(FileSave fileSave) throws Exception
    {
        System.out.printf("***********8");
        logger.info("******************************"+fileSave.getIp());

        jdbcTemplate=SpringBeanUtil.getBean(JdbcTemplate.class);


        if (jdbcTemplate==null)
        {
            System.out.printf("***********************空的");
        }else
        {
            System.out.printf("***********************有值");
        }
//        fileSaveRepository.save(fileSave);
    }
}
